import JSEncrypt from 'jsencrypt';

export default {
  encodeRSA(word, keyStr) {
    // 这个是公钥,有入参时用入参，没有入参用默认公钥
    keyStr = keyStr || 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCETwFz6JZ44hMQbhGJBcc7npfiIIFPGE3CScRnRr3bObFd2cMvNXY707Ziyztihu8Uqka99r+o0ZruOiw5X2qtlyiaqkY4bMfaomKej3QTC+fRKFNbhxeM5P20Ajzhv1A/h5LV3lkwYGCpovvf/TU4BZl/lRaN4VZ1Bb4L1LTuzwIDAQAB';
    // 创建对象
    const jsRsa = new JSEncrypt();
    // 设置公钥
    jsRsa.setPublicKey(keyStr);
    // 返回加密后结果
    return jsRsa.encrypt(word);
  }

}
